/**
 * @auther tedu
 * @date 2023/6/27 20:46
 */
package cn.tedu.hospital.admin.server.doctor.dao.persist.repository.impl;


import cn.tedu.hospital.admin.server.doctor.dao.persist.mapper.DoctorMapper;
import cn.tedu.hospital.admin.server.doctor.dao.persist.repository.IDoctorRepository;
import cn.tedu.hospital.admin.server.doctor.pojo.entity.Doctor;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Slf4j
@Repository
public class DoctorRepositoryImpl implements IDoctorRepository {
    @Autowired
    private DoctorMapper doctorMapper;
    public DoctorRepositoryImpl() {
        log.info("创建存储库对象：TagRepositoryImpl");
    }
    public int insert(Doctor doctor) {
        log.debug("开始向【标签表】中插入数据：{}", doctor);
        return doctorMapper.insert(doctor);
    }

    @Override
    public int countByName(String name) {
        log.debug("根据名称【{}】统计【标签表】中的数据的数量", name);
        QueryWrapper<Doctor> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("name", name);
        return doctorMapper.selectCount(queryWrapper);
    }
}